import allure
from appium.webdriver.common.appiumby import AppiumBy

from tests.app.pages.edit_member_page import EditMemberPage
from tests.app.pages.wecom import Wecom


class MemberAndDepartmentManagementPage(Wecom):
    __MEMBERS_NAME = AppiumBy.XPATH, "//*[@resource-id = 'com.tencent.wework:id/h96']"

    def goto_member_page(self, member_name):
        with allure.step(f"进入【{member_name}】成员详情页"):
            self.find_and_click(AppiumBy.XPATH, f"//*[@text = '{member_name}']/../../following-sibling::*")
        return EditMemberPage(self.driver)

    @allure.step("获取成员列表")
    def get_members_name(self):
        members_name = self.finds(*self.__MEMBERS_NAME)
        return members_name
